package com.har.modules.business.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.toolkit.StringUtils;
import com.har.common.utils.PageUtils;
import com.har.common.utils.Query;
import com.har.modules.business.dao.TSuggestionDao;
import com.har.modules.business.entity.TSuggestionEntity;
import com.har.modules.business.service.TSuggestionService;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("tSuggestionService")
public class TSuggestionServiceImpl extends ServiceImpl<TSuggestionDao, TSuggestionEntity> implements TSuggestionService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        EntityWrapper<TSuggestionEntity> ew = new EntityWrapper<>();

        if(StringUtils.checkValNotNull(params.get("mobile"))) {
            ew.eq("mobile", params.get("mobile"));
        }

        if(StringUtils.checkValNotNull(params.get("date"))) {
            String[] dates = params.get("date").toString().split("~");
            ew.gt("create_time",dates[0].trim()+" 00:00:00");
            ew.lt("create_time",dates[1].trim()+" 23:59:59");
        }
        Page<TSuggestionEntity> page = this.selectPage(
                new Query<TSuggestionEntity>(params).getPage(),
                ew
        );

        return new PageUtils(page);
    }

}
